<template>
    <div>
        <button @click="exportData">导出数据</button>
    </div>
</template>

<script>
    import {exportToExcel} from "../util/jsonToExcel"

    export default {
        name: "JsonToExcelView",
        methods: {
            exportData() {
                // 假设您的数据是一个包含对象的数组
                const jsonData = [
                    { name: "tom", age: 30, city: "New York" },
                    { name: "lucy", age: 25, city: "San Francisco" },
                    { name: "linda", age: 40, city: "Los Angeles" }
                ];

                // 调用导出函数
                exportToExcel(jsonData, 'data1');
            }
        }
    }
</script>

<style scoped>

</style>